package com.team.controller.admin;

import com.github.pagehelper.PageInfo;
import com.team.pojo.AppInfo;
import com.team.pojo.AppInfoCondition;
import com.team.pojo.AppVersion;
import com.team.service.AppInfoService;
import com.team.service.AppVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller(value = "appInfoController2")
public class AppInfoController {
 @Autowired(required = false)
 private AppInfoService appInfoService;
 @Autowired(required = false)
 private AppVersionService appVersionService;
 @RequestMapping("/getAppNoPassInfo")
  public String getAppNoPassInfo(AppInfoCondition appInfoCondition, Model model){
    PageInfo<AppInfo> pageInfo=appInfoService.getNoPassAppInfo(appInfoCondition);
      //将查询的条件和分页信息填充到页面（回显)
      model.addAttribute("condition",appInfoCondition);
      model.addAttribute("pageInfo",pageInfo);
      return "backend/applist";
 }

// 查询当前审核app的信息
@RequestMapping("/goCheckApp")
 public String goCheckApp(Long id,Model model){
  //查询当前app信息的展示
  AppInfo appInfo=appInfoService.getCheckAppInfo(id);
  AppVersion appVersion=(AppVersion) appVersionService.getLastAppVersion(id);
  //当前app最新版本详情展示(填充页面）
   model.addAttribute("appInfo",appInfo);
   model.addAttribute("appVersion",appVersion);
   return "backend/appcheck";
 }
 @RequestMapping("/checkAppInfo")
 public String checkAppInfo(Long id,Long status){
  int temp=appInfoService.updateStatus(id, status);
  if (temp>0){
   return "redirect:getAppNoPassInfo";
  }else {
   return "error";
  }
 }
}
